/*
	The MIT License

	Copyright (c) 2008 IFMO/GameDev Studio

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/
// ui_font.h - 



struct fontCharInfo_s {
		float	xadvance;
		EVec2	uv0;
		EVec2	uv1;
		EVec2	offset;
		EVec2	glyph_size;
	};
	

class EFont : public IFont {
	public:
							EFont			( class EUserInterface *ui, const char *path );
							~EFont			( void );

		virtual const char	*Name			( void ) const { return path.c_str(); }						
		virtual const char	*GetFontImage	( void ) const { return font_image.c_str(); }
		virtual float		GetLineHeight	( void ) const { return line_height; }
		virtual float		GetBaseLine		( void ) const { return baseline; }
						
		virtual float		GetXAdvance		( uchar ch ) const { return char_info[ch].xadvance; }
		virtual EVec2		GetOffset		( uchar ch ) const { return char_info[ch].offset; }
		virtual EVec2		GetUV0			( uchar ch ) const { return char_info[ch].uv0; }
		virtual EVec2		GetUV1			( uchar ch ) const { return char_info[ch].uv1; }
		virtual EVec2		GetGlyphSize	( uchar ch ) const { return char_info[ch].glyph_size; }
		virtual float		GetKerning		( uchar first, char second ) const { return kernings[first][second]; }
		
		void			ShowInfo		( void ) const;
		
	protected:
		IConsole		*con;
		IFileSystem		*fs;
		
		string			path;
	
		string			font_face;
		
		string			font_image;
		float			line_height;
		float			baseline;
		float			scale_w, scale_h;
		fontCharInfo_s	char_info[256];
		signed char		kernings[256][256]; // [first][second]
		
		vector<uint16_t>	char_width;
	};